wayland: Look for cursor themes in $HOME
authorMatthias Clasen <mclasen@redhat.com>
Tue, 29 Jun 2021 20:57:15 +0000 (16:57 -0400)
committerLuca Bacci <luca.bacci982@gmail.com>
Fri, 25 Nov 2022 14:18:39 +0000 (15:18 +0100)
We should look in the same places that libXcursor does,
so add $XDG_DATA_HOME/icons and $HOME/.icons to the list.

Fixes: #4080
gdk/wayland/gdkdisplay-wayland.c

index f60f75a9a184a3754ce6b7b8067eceb79e314861..ddf2bf312ccd35f64c8792d783f4b578916e06a4 100644 (file)
@@ -1112,6 +1112,26 @@ gdk_wayland_display_init (GdkWaylandDisplay *display)
   display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
 }
 
+static struct wl_cursor_theme *
+try_load_theme (GdkWaylandDisplay *display_wayland,
+                const char        *dir,
+                gboolean           dotdir,
+                const char        *name,
+                int                size)
+{
+  struct wl_cursor_theme *theme = NULL;
+  char *path;
+
+  path = g_build_filename (dir, dotdir ? ".icons" : "icons", name, "cursors", NULL);
+
+  if (g_file_test (path, G_FILE_TEST_IS_DIR))
+    theme = wl_cursor_theme_create (path, size, display_wayland->shm);
+
+  g_free (path);
+
+  return theme;
+}
+
 static struct wl_cursor_theme *
 get_cursor_theme (GdkWaylandDisplay *display_wayland,
                   const char *name,
@@ -1121,16 +1141,18 @@ get_cursor_theme (GdkWaylandDisplay *display_wayland,
   struct wl_cursor_theme *theme = NULL;
   int i;
 
+  theme = try_load_theme (display_wayland, g_get_user_data_dir (), FALSE, name, size);
+  if (theme)
+    return theme;
+
+  theme = try_load_theme (display_wayland, g_get_home_dir (), TRUE, name, size);
+  if (theme)
+    return theme;
+
   xdg_data_dirs = g_get_system_data_dirs ();
   for (i = 0; xdg_data_dirs[i]; i++)
     {
-      char *path = g_build_filename (xdg_data_dirs[i], "icons", name, "cursors", NULL);
-
-      if (g_file_test (path, G_FILE_TEST_IS_DIR))
-        theme = wl_cursor_theme_create (path, size, display_wayland->shm);
-
-      g_free (path);
-
+      theme = try_load_theme (display_wayland, xdg_data_dirs[i], FALSE, name, size);
       if (theme)
         return theme;
     }